package com.huidu.bitrade.request;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum BinanceOrderType {
    MARKET(0, "MARKET","限价单"),
    LIMIT(1, "LIMIT","市价单"),
    STOP(2, "STOP","止损限价单"),
    STOP_MARKET(3, "STOP_MARKET","止损市价单"),
    TAKE_PROFIT(4, "TAKE_PROFIT","止盈限价单"),
    TAKE_PROFIT_MARKET(5, "TAKE_PROFIT_MARKET","止盈市价单"),
    TRAILING_STOP_MARKET(6, "TRAILING_STOP_MARKET","跟踪止损单");

    BinanceOrderType(Integer number, String value,String description) {
        this.code = number;
        this.description = description;
        this.value = value;
    }
    private Integer code;
    private String description;
    private String value;

    public static BinanceOrderType get(Integer code){
        Optional<BinanceOrderType> any;
        any = Arrays.stream(BinanceOrderType.class.getEnumConstants())
                .filter(e -> e.getCode().equals(code)).findAny();
        return any.orElse(null);
    }
}
